//
//  CWHomeForwardCell.swift
//  SinaBlog
//
//  Created by ChenWei on 15/12/1.
//  Copyright © 2015年 cw. All rights reserved.
//
 /// 转发微博的cell

import UIKit

class CWHomeForwardCell: CWHomeTableViewCell {
    
//    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
//        super.init(style: style, reuseIdentifier: reuseIdentifier)
//        
//        setupUI()
//    }
//
//    required init?(coder aDecoder: NSCoder) {
//        fatalError("init(coder:) has not been implemented")
//    }
    // MARK: - 内部方法
    override func setupUI() {
        super.setupUI()
        
        // 1.添加自己特有的控件
        contentView.insertSubview(coverView, belowSubview: pictureView)
        contentView.addSubview(retweetLabel)
        
        // 2.布局
        /// 2.1布局背景
        coverView.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(contentLabel.snp_bottom).offset(10)
            make.left.equalTo(contentView)
            make.right.equalTo(contentView)
            make.bottom.equalTo(pictureView).offset(10)
        }
        
        // 2.2布局转发正文
        retweetLabel.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(coverView).offset(10)
            make.left.equalTo(coverView).offset(10)
            make.right.equalTo(coverView)
        }
        
        // 2.3布局转发配图
        pictureView.snp_makeConstraints { (make) -> Void in
//            var margin = 10
//            if retweetLabel.text == nil {
//                NSLog(message: retweetLabel.frame.size)
//                NSLog(message: retweetLabel.text)
//                margin = 0
//            }
            make.top.equalTo(retweetLabel.snp_bottom).offset(10)
            make.left.equalTo(coverView).offset(10)
        }
    }
    
    // MARK: - 懒加载
    /// 转发内容的背景
    private lazy var coverView: UIView = {
        let cv = UIView()
        cv.backgroundColor = UIColor.lightGrayColor()

        return cv
    }()
    
    /// 转发内容
    private lazy var retweetLabel: UILabel = {
        let label = UILabel()
        label.numberOfLines = 0
        label.text = "转发微博转发微博转发微博转发微博转发微博转发微博转发微博"
        label.textColor = UIColor.blackColor()
        label.font = UIFont.systemFontOfSize(15)
        
        return label
    }()
    
}
